# **********************************************************************
# piezometer makefile
# Copyright (C) Muhammad Fauzilkamil Zainuddin <jerungkun@gmail.com>
# http://coderstalk.blogspot.com 
# **********************************************************************
CC=gcc
CFLAGS=-g -c -Wall

piezometer : src/main.o src/piezometer.o
	$(CC) -o $@ src/main.o src/piezometer.o

src/piezometer.o : src/piezometer.c
	$(CC) $(CFLAGS) -o $@ $<

src/main.o : src/main.c
	$(CC) $(CFLAGS) -o $@ $<

clean :
	@if test -e src/main.o ; then rm src/main.o; fi
	@if test -e src/piezometer.o ; then rm src/piezometer.o; fi
	@if test -e piezometer ; then rm piezometer; fi

install :
	install piezometer /usr/bin/piezometer
	install scripts/piezoproc /usr/bin/piezoproc
	mkdir -p /usr/share/piezometer
	install scripts/piezofunctions /usr/share/piezometer/piezofunctions
	install scripts/piezo-init /etc/init.d/piezometer
	update-rc.d piezometer defaults 99
	mkdir -p /etc/piezometer
	install conf/piezometer.conf /etc/piezometer/piezometer.conf

uninstall :
	/etc/init.d/piezometer stop
	update-rc.d -f piezometer remove
	rm /etc/init.d/piezometer
	rm -rf /usr/share/piezometer
	rm -rf /etc/piezometer
	rm /usr/bin/piezoproc
	rm /usr/bin/piezometer
	
